#ifndef _PAGE_INFO_HPP
#define _PAGE_INFO_HPP

#define SHOW_INFO_ON_SCREEN 1

static lv_obj_t *pageRoot;
static lv_obj_t *infoLabel;


static int pageInfoWidth = CONFIG_SCREEN_WIDTH - 50;
static int pageInfoHeight = CONFIG_SCREEN_HEIGHT - CONFIG_TOP_STATUS_BAR_HEIGHT - 50;

// static void pageInfoRotA() {

// }
// static void pageInfoRotB() {

// }
// static void pageInfoRotC() {

// }

// static void pageInfoRotSet() {

// }

void pageInfoShowFun() {

}


void pageInfoInit() {
	LVMT;
	pageRoot = lv_obj_create(pageInfo);
	lv_obj_remove_style_all(pageRoot);
	lv_obj_center(pageRoot);
	lv_obj_set_style_bg_color(pageRoot, LV_COLOR_WHITE, 0);
	lv_obj_set_style_bg_opa(pageRoot, LV_OPA_COVER, 0);
	lv_obj_set_size(pageRoot, pageInfoWidth, pageInfoHeight);
	lv_obj_set_style_outline_color(pageRoot, LV_COLOR_WHITE, 0);
	lv_obj_set_style_outline_opa(pageRoot, LV_OPA_COVER, 0);
	lv_obj_set_style_outline_width(pageRoot, 10, 0);

	infoLabel = lv_label_create(pageRoot);
	lv_obj_remove_style_all(infoLabel);
	lv_obj_set_style_width(infoLabel, pageInfoWidth, 0);
	lv_obj_set_style_height(infoLabel, LV_SIZE_CONTENT, 0);
	lv_obj_set_align(infoLabel, LV_ALIGN_TOP_MID);
	lv_obj_set_style_text_align(infoLabel, LV_TEXT_ALIGN_LEFT, 0);
	lv_label_set_text(infoLabel, "");
	
	LVMG;
}


void pageInfoAdd(char *info) {
	#if SHOW_INFO_ON_SCREEN == 1
	if(pageCurrent(PAGE_INFO)) {
		if(strcmp(lv_label_get_text(infoLabel), "") != 0) {
			LVMT;
			lv_label_ins_text(infoLabel, LV_LABEL_POS_LAST, "\n");
			LVMG;
		}
		LVMT;
		lv_label_ins_text(infoLabel, LV_LABEL_POS_LAST, info);
		LVMG;
		int height = lv_obj_get_height(infoLabel);
		if(height > pageInfoHeight) {
			LVMT;
			lv_obj_scroll_to_y(pageRoot, 1000, 0);
			LVMG;
		}
	}
	#else
	log("page info =%d", pageCurrent(PAGE_INFO));
	#endif
}

#endif